home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / cpptut22.zip / NEWDATE.CPP < prev    next >
C/C++ Source or Header  |  1992-01-20  |  523b  |  21 lines

  1.                                      // Chapter 7 - Program 10
  2. #include "newdate.h"
  3.  
  4. extern int days[];
  5.  
  6.          // This routine ignores leap year for simplicity, and adds
  7.          //  the days in each month for all months less than the
  8.          //  current month, then adds the days in the current month
  9.          //  up to today.
  10. int new_date::get_day_of_year(void)
  11. {
  12. int index = 0;
  13.  
  14.    day_of_year = 0;
  15.  
  16.    while (index < month)
  17.       day_of_year += days[index++];
  18.  
  19.    return (day_of_year += day);
  20. }
  21.